package com.task.server.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.task.mapper.UserMapper;
import com.task.pojo.User;
import com.task.server.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
 * @author JiaFuJun
 * @version v1.0
 * @date 2020-01-04
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public void insert(User record) {
        userMapper.insert(record);
    }

    @Override
    public void update(User record){
        userMapper.update(record);
    }

    @Override
    public void del(Integer id){
        userMapper.del(id);
    }

    @Override
    public User selectByPrimaryKey(Integer id){
        return userMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<User> getList(User record){
        return userMapper.selectByRecord(record);
    }

    @Override
    public PageInfo<User> pageList(User record, Integer pageNo, Integer pageSize){
        PageHelper.startPage(pageNo, pageSize);
        List<User> list = userMapper.selectByRecord(record);
        return new PageInfo<>(list);
    }

    @Override
    public User getUser(String account,String phone) {
        return userMapper.getUser(account,phone);
    }

}